<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta property="og:type" content="website">
<meta property="og:title" content="smallmuou&#39;s blog">
<meta property="og:url" content="http://smallmuou.gitee.io/blog/page/10/index.html">
<meta property="og:site_name" content="smallmuou&#39;s blog">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="smallmuou&#39;s blog">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://smallmuou.gitee.io/blog/page/10/"/>





  <title>smallmuou's blog</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">smallmuou's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"><a href="https://github.com/smallmuou">https://github.com/smallmuou</a></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/blog/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/12/22/2016-12-22-跨域请求(CORS)要点/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/12/22/2016-12-22-跨域请求(CORS)要点/" itemprop="url">跨域请求(CORS)要点</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-12-22T00:00:00+08:00">
                2016-12-22
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/前端/" itemprop="url" rel="index">
                    <span itemprop="name">前端</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>前端开发的童鞋，应该都有听过跨域请求，但这其中的细节可能还不清楚，比如：</p>
<pre>
* 什么是跨域请求？
* 为什么会存在跨域请求？
* 跨域请求是怎么工作的？
* 如何解决跨域请求？
</pre>

<h3 id="1-什么是跨域请求"><a href="#1-什么是跨域请求" class="headerlink" title="1. 什么是跨域请求"></a>1. 什么是跨域请求</h3><p>跨域请求 - 访问其他域名的资源，随着业务的复杂化及前后端的分离，我们需要经常访问其他域名的资源，因此这里就涉及到跨域访问，下图给出了跨域访问的例子</p>
<p><img src="https://mdn.mozillademos.org/files/14295/CORS_principle.png" alt="image"></p>
<h3 id="2-为什么会存在跨域请求"><a href="#2-为什么会存在跨域请求" class="headerlink" title="2. 为什么会存在跨域请求"></a>2. 为什么会存在跨域请求</h3><p>可能有童鞋就说了，何必这么麻烦，直接允许访问不就行了，也许前期就是这样，于是就出现了CSRF（跨站请求伪造），可以看下图：<br><img src="http://pic002.cnblogs.com/img/hyddd/200904/2009040916453171.jpg" alt="image"></p>
<p>因此网站A就必须添加访问限制，即决策是否允许网站B访问</p>
<h3 id="3-跨域请求是怎么工作的"><a href="#3-跨域请求是怎么工作的" class="headerlink" title="3. 跨域请求是怎么工作的"></a>3. 跨域请求是怎么工作的</h3><p>跨域请求针对不同的请求会采用不用的策略，这里罗列如下：</p>
<h5 id="3-1-简单模式（Simple-requests）"><a href="#3-1-简单模式（Simple-requests）" class="headerlink" title="3.1 简单模式（Simple requests）"></a>3.1 简单模式（Simple requests）</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">请求方法:</span><br><span class="line">	GET</span><br><span class="line">	HEAD</span><br><span class="line">	POST</span><br><span class="line">请求头:</span><br><span class="line">	Accept</span><br><span class="line">	Accept-Language</span><br><span class="line">	Content-Language</span><br><span class="line">	Content-Type</span><br><span class="line">Content-Type:</span><br><span class="line">	application/x-www-form-urlencoded</span><br><span class="line">	multipart/form-data</span><br><span class="line">	text/plain</span><br></pre></td></tr></table></figure>
<p>满足以上特征的请求就是Simple request，采用如下工作模式:</p>
<ul>
<li>浏览器从网站B获取html资源</li>
<li>浏览器发送请求到网站A，并携带网站B的Origin，如Server-b.com</li>
<li>网站A检测自身的Access-Control-Allow-Origin是否包含Origin，如果包含返回正确数据，否则返回空</li>
</ul>
<p><img src="https://mdn.mozillademos.org/files/14293/simple_req.png" alt="image"></p>
<p>PS： Access-Control-Allow-Origin: * 表示允许所有网站方法</p>
<h5 id="3-2-预检模式（Preflighted-requests）"><a href="#3-2-预检模式（Preflighted-requests）" class="headerlink" title="3.2 预检模式（Preflighted requests）"></a>3.2 预检模式（Preflighted requests）</h5><p>除了简单请求外，其他请求访问前需要先发一条预检请求，比如采用OPTIONS，采用如下工作模式:</p>
<ul>
<li>浏览器从网站B获取html资源</li>
<li>浏览器发送OPTIONS请求，并携带如下信息<ul>
<li>Origin - 网站B域名</li>
<li>Access-Control-Request-Method - 待请求方法，如POST</li>
<li>Access-Control-Request-Headers - 待请求头信息</li>
</ul>
</li>
<li>网站A检测自身的Origin、Access-Control-Allow-Methods、Access-Control-Allow-Headers是否包含客户端发送的值</li>
<li>如果包含，则返回200，浏览器发送真正的请求（也需要携带CROS信息），服务器返回正确数据</li>
<li>如果不包含，则返回错误，并返回Origin、Access-Control-Allow-Methods、Access-Control-Allow-Headers</li>
</ul>
<p><img src="https://mdn.mozillademos.org/files/14289/prelight.png" alt="image"></p>
<h3 id="4-常见错误"><a href="#4-常见错误" class="headerlink" title="4. 常见错误"></a>4. 常见错误</h3><ul>
<li>4.1 Access-Control-Allow-Origin不匹配</li>
</ul>
<p>一般会报如下错误：<code>已拦截跨源请求：同源策略禁止读取位于 http://127.0.0.1:19110/uptoken 的远程资源。（原因：CORS 头 &#39;Access-Control-Allow-Origin&#39; 不匹配 &#39;1&#39;）</code></p>
<p>解决方法：检测服务端配置的Access-Control-Allow-Origin，应该包含前端所在服务的域名</p>
<ul>
<li>4.2 Access-Control-Allow-Headers不匹配</li>
</ul>
<p>一般会报如下错误：<code>已拦截跨源请求：同源策略禁止读取位于 http://127.0.0.1:19110/uptoken 的远程资源。（原因：来自 CORS 预检通道的 CORS 头 &#39;Access-Control-Allow-Headers&#39; 的令牌 &#39;if-modified-since&#39; 无效）</code></p>
<p>解决方法：检测服务端配置的Access-Control-Allow-Headers，应该包含前端发送的Access-Control-Request-Headers（可以抓包看前端发送的数据）</p>
<h3 id="更多"><a href="#更多" class="headerlink" title="更多"></a>更多</h3><ol>
<li>跨域是浏览器行为</li>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS" target="_blank" rel="noopener">HTTP access control (CORS)</a></li>
<li><a href="http://www.cnblogs.com/hyddd/archive/2009/04/09/1432744.html" target="_blank" rel="noopener">浅谈CSRF攻击方式</a></li>
</ol>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/12/16/2016-12-16-Chrome google不根据VPS跳转到对应域名/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/12/16/2016-12-16-Chrome google不根据VPS跳转到对应域名/" itemprop="url">Chrome google不根据VPS跳转到对应域名</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-12-16T00:00:00+08:00">
                2016-12-16
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/其他/" itemprop="url" rel="index">
                    <span itemprop="name">其他</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>在启用VPS后，各位可能会发现使用Chome进行Google搜索时经常会跳转到VPS所在地区的域名，如<a href="https://www.google.co.jp，于是出来了一大堆日文（太影响阅读了），今天又去搜索了下解决方法，最终发现其实只要简单的设置就可以" target="_blank" rel="noopener">https://www.google.co.jp，于是出来了一大堆日文（太影响阅读了），今天又去搜索了下解决方法，最终发现其实只要简单的设置就可以</a>.</p>
<h3 id="解决方法："><a href="#解决方法：" class="headerlink" title="解决方法："></a>解决方法：</h3><ul>
<li><p>在google页面搜索栏下面一栏：<code>全部</code> <code>图片</code> <code>新闻</code> <code>视频</code> <code>地图</code> <code>更多</code> <code>设置</code> <code>工具</code></p>
</li>
<li><p>点击<code>设置</code> -&gt; <code>语言</code> 设置成中文或者英文 </p>
</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/12/16/2016-12-16-三层交换机工作流程/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/12/16/2016-12-16-三层交换机工作流程/" itemprop="url">三层交换机工作流程</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-12-16T00:00:00+08:00">
                2016-12-16
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/运维/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>引言：对于三层交换机这个名词，大家应该不陌生，但大家是否正真了解它，对于它我有太多的疑问：</p>
<pre>
* 为什么叫三层？
* 为什么要有三层，二层不够？
* 其工作流程是怎样？
* 为什么同时可以工作在二层模式也可以工作在三层模式下？
* 什么是一次路由多次转发？
* ...
</pre>

<p>这里面含有着种种的疑问，在这里我也会给出我理解的答案：</p>
<ul>
<li>为什么叫三层？ - 工作在网络层（OSI中属于第三层）</li>
<li>为什么要有三层，二层不够？ - 应该是为了满足大型网络的通信效率，二层交换机承受的主机数毕竟有限，而路由器效率不高</li>
</ul>
<p>————————–我是分割线————————</p>
<p>以上都是概念性的，下面来点真功夫，先上图</p>
<pre>
 ------------------------------
|           三层交换机              |
|   -------         -------       | 
|  |  网关1 |      |  网关2  |     |
 ----1---2-------------3-------
     |   |             |
     |   |             |
     |   |             |
     |   |             |
     A   B             C

1、2、3 - 交换机网口
网关1 - 192.168.2.1
网关2 - 192.168.3.1
主机A - 192.168.2.2
主机B - 192.168.2.3
主机C - 192.168.3.2
</pre>

<ul>
<li><p>二层交换机工作流程</p>
<ul>
<li>从一个端口接收数据包，解析源MAC，并更新CAM表</li>
<li>解析目的MAC，并从CAM表查找该MAC对应的网口</li>
<li>若找到则直接复制数据包到相应网口上</li>
<li>若未找到，则广播数据到所有端口，并记录结果到CAM中</li>
</ul>
</li>
<li><p>工作在二层（主机A to 主机B）</p>
<ul>
<li>交换机检测主机A与主机B的IP，发现是在同一个网络下</li>
<li>采用二层交换机工作流程与B通信（参考二层交换机工作流程）</li>
</ul>
</li>
<li><p>工作在三层（主机A to 主机C）</p>
<ul>
<li>交换机发现主机A与主机C不在同一个网络下</li>
<li>通过路由规则，网关1将数据发给网关2（参看路由器路由过程）</li>
<li>网关2将数据发给主机C</li>
</ul>
</li>
</ul>
<p>————————–我是分割线————————</p>
<p>从以上可以看成，若主机在同一个网段，则采用二层工作模式，若主机不在同一个网络，则采用三层工作模式</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/12/09/2016-12-09-Alfred workflow若干要点/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/12/09/2016-12-09-Alfred workflow若干要点/" itemprop="url">Alfred workflow若干要点</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-12-09T00:00:00+08:00">
                2016-12-09
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/工具/" itemprop="url" rel="index">
                    <span itemprop="name">工具</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>Alfred workflow真是个神器，自从上手后，就割舍不掉，目前很多原来繁琐的动作都可以通过简单的方式进行，虽然网上已经有很多别人写好的workflow，但总是不够用，毕竟各自的偷懒点不同，因此就必须会workflow的编写，本文将为大家介绍最为常用的技巧.</p>
<h3 id="工作模式"><a href="#工作模式" class="headerlink" title="工作模式"></a>工作模式</h3><p> Alfred workflow，顾名思义是以流的方式来进行工作的，从<code>输入 -&gt; 动作 -&gt; 输出</code>，非常开放，可以说是一个精妙的设计.</p>
<ul>
<li>输入<ul>
<li>Triggers - 触发器<ul>
<li>Hotkeys - 快捷键</li>
<li>Remote - 远程</li>
<li>…</li>
</ul>
</li>
<li>Inputs - 输入源<ul>
<li>Keywords - 关键字</li>
<li>Script Filter - 脚本过滤器</li>
<li>…</li>
</ul>
</li>
</ul>
</li>
<li>动作<ul>
<li>Actions - 动作<ul>
<li>System Command - 系统命令</li>
<li>Launch App - 运行程序</li>
<li>Open URL - 打开网页</li>
<li>Run Script - 运行脚本</li>
<li>…</li>
</ul>
</li>
</ul>
</li>
<li>输出<ul>
<li>Outputs - 输出<ul>
<li>Post Notification - 系统通知</li>
<li>Copy To Clipboard - 复制到系统粘贴板</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 id="要点"><a href="#要点" class="headerlink" title="要点"></a>要点</h3><h5 id="1-参数传递-通过标准输入输出来实现"><a href="#1-参数传递-通过标准输入输出来实现" class="headerlink" title="1. 参数传递 - 通过标准输入输出来实现"></a>1. 参数传递 - 通过标准输入输出来实现</h5><ul>
<li>第一级一般是用户输入的，如在Keywords输入源中可以选择是否带参数</li>
<li>上一级的结果直接输出到stdout作为下一级的参数，下一级可以通过{query}来获取</li>
</ul>
<p>例如：我需要把hello alfred输出到下一级</p>
<p><pre><br>echo -n “hello alfred”<br></pre><br>PS: 此处必须加-n，否则默认是带换行符</p>
<h5 id="2-脚本过滤器（Script-Filter）"><a href="#2-脚本过滤器（Script-Filter）" class="headerlink" title="2. 脚本过滤器（Script Filter）"></a>2. 脚本过滤器（Script Filter）</h5><p>有时候你需要直接在alfred的下拉列表中展现结果（非常拉风），你就需要用到Script Filter.<br><img src="https://www.alfredapp.com/help/workflows/inputs/script-filter/json-example.png" alt="image"></p>
<p>Alfred是通过XML来展现输出，XML格式如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span><br><span class="line">&lt;items&gt;</span><br><span class="line">    &lt;item valid=&quot;YES&quot;&gt;</span><br><span class="line">        &lt;title&gt;标题&lt;/title&gt;</span><br><span class="line">        &lt;subtitle&gt;子标题&lt;/subtitle&gt;</span><br><span class="line">		&lt;arg&gt;下一级参数&lt;/arg&gt;</span><br><span class="line">		...</span><br><span class="line">    &lt;/item&gt;</span><br><span class="line">	...</span><br><span class="line">&lt;/items&gt;</span><br></pre></td></tr></table></figure>
<p>PS：Alfred 3.0引入了JSON作为输出</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&#123;&quot;items&quot;: [</span><br><span class="line">    &#123;</span><br><span class="line">        &quot;title&quot;: &quot;标题&quot;,</span><br><span class="line">        &quot;subtitle&quot;: &quot;子标题&quot;,</span><br><span class="line">        &quot;arg&quot;: &quot;下一级参数&quot;,</span><br><span class="line">        ...</span><br><span class="line">    &#125;</span><br><span class="line">]&#125;</span><br></pre></td></tr></table></figure>
<table>
<thead>
<tr>
<th style="text-align:left">参数</th>
<th style="text-align:left">说明</th>
<th>备注</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">title</td>
<td style="text-align:left">标题</td>
</tr>
<tr>
<td style="text-align:left">subtitle</td>
<td style="text-align:left">子标题</td>
</tr>
<tr>
<td style="text-align:left">arg</td>
<td style="text-align:left">下一级参数</td>
<td>当选择此项后，会将此参数作为输出传递给下一级</td>
</tr>
</tbody>
</table>
<p>更多参数详见<a href="https://www.alfredapp.com/help/workflows/inputs/script-filter/json/" target="_blank" rel="noopener">这里</a></p>
<p>下面是我编写查看本机ip的DEMO</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">ip=$(ifconfig|sed -n &apos;/en/,/status/p&apos;|awk &apos;/broadcast/&#123;print $2&#125;&apos;)</span><br><span class="line"></span><br><span class="line">cat &lt;&lt; EOF</span><br><span class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span><br><span class="line">&lt;items&gt;</span><br><span class="line">    &lt;item valid=&quot;YES&quot;&gt;</span><br><span class="line">        	&lt;title&gt;$ip&lt;/title&gt;</span><br><span class="line">		&lt;arg&gt;$ip&lt;/arg&gt;</span><br><span class="line">    &lt;/item&gt;</span><br><span class="line">&lt;/items&gt;</span><br><span class="line">EOF</span><br></pre></td></tr></table></figure>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/12/08/2016-12-08-font-awesome 字体文件路径如何配置/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/12/08/2016-12-08-font-awesome 字体文件路径如何配置/" itemprop="url">font-awesome 字体文件路径如何配置</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-12-08T00:00:00+08:00">
                2016-12-08
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/前端/" itemprop="url" rel="index">
                    <span itemprop="name">前端</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>最近工程中有使用到font-awesome，其中涉及到font路径的配置纠结了我好长一段时间，经过探索发现，该路径是相对于css路径.</p>
<h3 id="css模式"><a href="#css模式" class="headerlink" title="css模式"></a>css模式</h3><p>当直接使用css模式，则从官网下载后的目录结构是：(3.2.1)</p>
<pre>
starnet:Font-Awesome-3.2.1 $ tree .
.
├── css
│   ├── font-awesome-ie7.css
│   ├── font-awesome-ie7.min.css
│   ├── font-awesome.css
│   └── font-awesome.min.css
├── font
│   ├── FontAwesome.otf
│   ├── fontawesome-webfont.eot
│   ├── fontawesome-webfont.svg
│   ├── fontawesome-webfont.ttf
│   └── fontawesome-webfont.woff
└── scss
    ├── _bootstrap.scss
    ├── _core.scss
    ├── _extras.scss
    ├── _icons.scss
    ├── _mixins.scss
    ├── _path.scss
    ├── _variables.scss
    ├── font-awesome-ie7.scss
    └── font-awesome.scss
</pre>
PS: 此处只列出相关文件，其他文件不列出

打开font-awesome.css可以看到如下信息：

<pre>
@font-face {
  font-family: 'FontAwesome';
  src: url('../font/fontawesome-webfont.eot?v=3.2.1');
  src: url('../font/fontawesome-webfont.eot?#iefix&v=3.2.1') format('embedded-opentype'), url('../font/fontawesome-webfont.woff?v=3.2.1') format('woff'), url('../font/fontawesome-webfont.ttf?v=3.2.1') format('truetype'), url('../font/fontawesome-webfont.svg#fontawesomeregular?v=3.2.1') format('svg');
  font-weight: normal;
  font-style: normal;
}
</pre>
PS: ../font/fontawesome-webfont.eot?v=3.2.1路径是以css文件所在位置为当前位置

### sass模式
sass是中间文件，通过import后，sass文件会合并成一个，因此生成的css可能就不是font-awesome.css，因此路径也就不是`../font`，有两种做法：

* 方法一：修改路径配置
vim _variables.scss

<pre>
$fa-font-path:        "../font" !default;
</pre>

<ul>
<li>方法二：拷贝字体</li>
</ul>
<pre>
cp font css文件上一级
</pre>


          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/11/18/2016-11-18-iOS静态库的链接与加载/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/11/18/2016-11-18-iOS静态库的链接与加载/" itemprop="url">iOS静态库的链接与加载</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-11-18T00:00:00+08:00">
                2016-11-18
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/IOS/" itemprop="url" rel="index">
                    <span itemprop="name">IOS</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>引言：研究iOS静态库的链接与加载是源自这个问题：<code>为何引用同一个SDK，在真机可以编译成功，而在模拟器在出现duplicate symbol?</code>,一时间无法理解，按道理说如果出现duplicate symbol，说明代码中应该有重复定义的部分，而为何真机又ok，难道真机屏蔽了部分代码？带着这些疑问和猜想，进行如下实验</p>
<h3 id="实验"><a href="#实验" class="headerlink" title="实验"></a>实验</h3><p>实践才是检验真理的唯一标准</p>
<ul>
<li>Demo<ul>
<li>Testlib1  <pre>
  void hello() {
      printf("Testlib1: hello\n");
  }
  void hello2() {
      printf("Testlib1: hello1\n");
  }</pre></li>
<li>Testlib2  <pre>
  void hello() {
      printf("Testlib2: hello\n");
  }
  void hello2() {
      printf("Testlib2: hello2\n");
  }</pre>

</li>
</ul>
</li>
</ul>
<p>PS: 以上是测试DEMO工程框架, Demo为主工程，包含2个静态库工程：Testlib1, Testlib2</p>
<table>
<thead>
<tr>
<th style="text-align:left">编号</th>
<th style="text-align:left">CPU架构</th>
<th>链接标识</th>
<th>库链接顺序</th>
<th>测试代码</th>
<th>Symbol</th>
<th>输出</th>
<th>备注</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">1</td>
<td style="text-align:left">arm64</td>
<td>空</td>
<td>Testlib1.framework<br>Testlib2.framework</td>
<td>hello()</td>
<td>T _hello<br>T _hello1</td>
<td>Testlib1: hello</td>
<td>原始</td>
</tr>
<tr>
<td style="text-align:left">2</td>
<td style="text-align:left">arm64</td>
<td>空</td>
<td>Testlib2.framework<br>Testlib1.framework</td>
<td>hello()</td>
<td>T _hello<br>T _hello2</td>
<td>Testlib2: hello</td>
<td>调整库链接顺序</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">arm64</td>
<td>空</td>
<td>Testlib1.framework<br>Testlib2.framework</td>
<td>hello();hello1()</td>
<td>T _hello<br>T _hello1</td>
<td>Testlib1: hello;Testlib1: hello1</td>
<td>打印hello1</td>
</tr>
<tr>
<td style="text-align:left">4</td>
<td style="text-align:left">arm64</td>
<td>空</td>
<td>Testlib1.framework<br>Testlib2.framework</td>
<td>hello();hello2()</td>
<td>T _hello<br>T _hello1<br>T _hello2</td>
<td>Testlib2: hello;Testlib2: hello2</td>
<td>打印hello2</td>
</tr>
<tr>
<td style="text-align:left">5</td>
<td style="text-align:left">arm64</td>
<td>-all_load</td>
<td>Testlib1.framework<br>Testlib2.framework</td>
<td>hello();hello2()</td>
<td>报错：duplicate symbol _hello</td>
<td></td>
<td>链接标识+打印hello2</td>
</tr>
<tr>
<td style="text-align:left">11</td>
<td style="text-align:left">x86_64</td>
<td>空</td>
<td>Testlib1.framework<br>Testlib2.framework</td>
<td>hello()</td>
<td>T _hello<br>T _hello1</td>
<td>Testlib1: hello</td>
<td>模拟器</td>
</tr>
<tr>
<td style="text-align:left">12</td>
<td style="text-align:left">x86_64</td>
<td>空</td>
<td>Testlib2.framework<br>Testlib1.framework</td>
<td>hello()</td>
<td>T _hello<br>T _hello2</td>
<td>Testlib2: hello</td>
<td>模拟器+调整库链接顺序</td>
</tr>
<tr>
<td style="text-align:left">13</td>
<td style="text-align:left">x86_64</td>
<td>空</td>
<td>Testlib1.framework<br>Testlib2.framework</td>
<td>hello();hello1()</td>
<td>T _hello<br>T _hello1</td>
<td>Testlib1: hello;Testlib1: hello1</td>
<td>模拟器+打印hello1</td>
</tr>
<tr>
<td style="text-align:left">14</td>
<td style="text-align:left">x86_64</td>
<td>空</td>
<td>Testlib1.framework<br>Testlib2.framework</td>
<td>hello();hello2()</td>
<td>报错：duplicate symbol _hello</td>
<td></td>
<td>模拟器+打印hello2</td>
</tr>
</tbody>
</table>
<h3 id="结论"><a href="#结论" class="headerlink" title="结论"></a>结论</h3><ul>
<li>库加载是通过配置的顺序进行加载，当发现需要调用的接口都已经定义，则不在继续加载，否则继续加载（根据1、2、3得出）</li>
<li>后者加载的接口会覆盖前面库的接口（根据4得出）</li>
<li>模拟器下不允许重复定义（根据14得出）</li>
<li>-all_load下不允许接口重定义（根据5得出）</li>
</ul>
<h3 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h3><p>通过上述结论，可以更好的解释：<code>为何引用同一个SDK，在真机可以编译成功，而在模拟器在出现duplicate symbol?</code>，当然以上测试是在XCode 8.0及iPhone 5s 10.0.1上进行的.我并未找到官方说明，若哪位童鞋有找到apple文档，可以告知我.</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/11/18/2016-11-18-关于CSS预编译器SASS/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/11/18/2016-11-18-关于CSS预编译器SASS/" itemprop="url">关于CSS预编译器SASS</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-11-18T00:00:00+08:00">
                2016-11-18
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/前端/" itemprop="url" rel="index">
                    <span itemprop="name">前端</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>关于sass其实在早些时候已经听说过，但一直没有用上，今天在前端同事答辩的过程中再次进入视线，经过了解，在sass中可以定义变量，感觉非常欣喜，因为在之前的编写css过程中，发现很多内容都需要重复写多边，于是一直想寻找一种更高级的css编写技术，果不其然，sass解决了我的痛点，接下来我来详细介绍下sass带来的好处.</p>
<h3 id="变量"><a href="#变量" class="headerlink" title="变量"></a>变量</h3><p>变量是一个非常神奇的产物，有了它，我们可以实现『一处改动、多处生效』</p>
<pre>
$theme-color: #F00; //定义单个变量
$colors:#F00 #CCC;  //定义数组变量

.header {
    color:nth($colors, 1); //取第一个值
    background: $theme-color;
}
</pre>

<h3 id="嵌套"><a href="#嵌套" class="headerlink" title="嵌套"></a>嵌套</h3><p>直接上代码</p>
<p>css下写法</p>
<pre>
.list {
    margin-top: 10;
}
.list li {
    padding-left: 15px;
}
.list a {
    color: #333;
}
.list a:hover {
    text-decoration: none;
}
</pre>

<p>sass下写法</p>
<pre>
.list {
    margin-top: 10px;
    li {
        padding-left: 15px;
    }
    a {
        color: #333;
        &:hover {
            text-decoration: none;
        }
    }
}
</pre>
PS: &表示父元素选择器


### 继承extend

<pre>
.text {
    color: #333;
    font-size: 14px;
    margin: 10px 0;
}
.error {
    @extend .text;
    color: #f00;
}


<p>生成css</p>
<pre>
.text, .error {
    color: #333;
    font-size: 14px;
    margin: 10px 0;
}

.error {
    color: #f00;
}
</pre>

<h3 id="占位选择器"><a href="#占位选择器" class="headerlink" title="占位选择器%"></a>占位选择器%</h3><pre>
%text {
    color: #333;
    font-size: 14px;
    margin: 10px 0;
}
.warn {
    @extend %text;
    color: #fdd;
}
.error {
    @extend %text;
    color: #f00;
}
</pre>

<p>生成css</p>
<p><pre><br>.warn, .error {<br>    color: #333;<br>    font-size: 14px;<br>    margin: 10px 0;<br>}<br>.warn {<br>    color: #fdd;<br>}<br>.error {<br>    color: #f00;<br>}<br></pre><br>PS： 可以发现没有text字段，只有warn、error，类似于虚类</p>
<h3 id="条件判断"><a href="#条件判断" class="headerlink" title="条件判断"></a>条件判断</h3><p><pre><br>body {<br>    @if $theme == red {<br>        background: rgba(255, 0, 0, 0.5);<br>    } @else if $theme == yellow {<br>        background: rgba(255, 255, 0, 0.5);<br>    } @else if $theme == black {<br>        background: rgba(0, 0, 0, 0.5);<br>    }<br>}<br></pre><br>PS: 使用@if判断</p>
<p><pre><br>@if($condition, $condition_true, $condition_false)<br></pre><br>PS: 三目运算</p>
</pre>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/11/17/2016-11-17-如何理解JSP/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/11/17/2016-11-17-如何理解JSP/" itemprop="url">如何理解JSP</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-11-17T00:00:00+08:00">
                2016-11-17
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/后端/" itemprop="url" rel="index">
                    <span itemprop="name">后端</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>虽然JSP技术有些过时，但很多网站还是使用JSP，于是想了解下JSP的来源，即为什么会有JSP？</p>
<h3 id="Servlet"><a href="#Servlet" class="headerlink" title="Servlet"></a>Servlet</h3><p>在理解JSP之前，先来了解下Servlet，简单地说Servlet是Java服务端处理请求的单元，如HtttpServlet用来处理HTTP请求，里面包含doGet、doPost等函数用来出来GET、POST请求.</p>
<h3 id="JSP"><a href="#JSP" class="headerlink" title="JSP"></a>JSP</h3><p>有了Servlet，当我请求某个html页面时，servlet的doGet方法将html页面写入到response对象中，各位想想如果在代码中将html的内容一一print到response对象中，效率可想而知，JSP就是在此情况下产生的，JSP文件中同时包含了java和html部分，当用于发请求时，服务端将JSP编译成servlet，即将原先需要人工print到response的部分改为代码实现</p>
<h3 id="理解"><a href="#理解" class="headerlink" title="理解"></a>理解</h3><p>说白点，JSP就是一个html模板</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/11/04/2016-11-04-MacOSX终端下翻墙/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/11/04/2016-11-04-MacOSX终端下翻墙/" itemprop="url">MacOSX终端下翻墙</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-11-04T00:00:00+08:00">
                2016-11-04
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/工具/" itemprop="url" rel="index">
                    <span itemprop="name">工具</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>最近需要安装gitbook，发现老卡死，猜测应该是由于那个wall，于是想找下如何在终端下使用shadowsocks来跨过那个wall，果然，通过google发现可以通过proxychains-ng来实现，亲测可行，记录于此.</p>
<h3 id="前提步骤：确保shadowsocks运行正常"><a href="#前提步骤：确保shadowsocks运行正常" class="headerlink" title="前提步骤：确保shadowsocks运行正常"></a>前提步骤：确保shadowsocks运行正常</h3><p>PS：不懂shadowsocks的童鞋自查，这里不做说明</p>
<p>查看下本地端口1080是否存在</p>
<pre>
nmap localhost

输出：

Starting Nmap 7.12 ( https://nmap.org ) at 2016-11-04 10:32 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00032s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 960 closed ports, 29 filtered ports
PORT     STATE SERVICE
25/tcp   open  smtp
80/tcp   open  http
111/tcp  open  rpcbind
587/tcp  open  submission
999/tcp  open  garcon
1021/tcp open  exp1
1023/tcp open  netvenuechat
1080/tcp open  socks                 <---------- 1="" 2049="" 4000="" 8090="" 说明我的shadowsocks已正常运行="" tcp="" open nfs="" remoteanything="" unknown="" nmap="" done:="" ip="" address="" (1="" host="" up)="" scanned="" in="" 5.45="" seconds="" <="" pre="">


<h3 id="步骤一：安装proxychains-ng"><a href="#步骤一：安装proxychains-ng" class="headerlink" title="步骤一：安装proxychains-ng"></a>步骤一：安装proxychains-ng</h3><pre>
sudo brew install proxychains-ng
</pre>

<h3 id="步骤二：配置"><a href="#步骤二：配置" class="headerlink" title="步骤二：配置"></a>步骤二：配置</h3><pre>
# 创建目录，默认是没有
mkdir ~/.proxychains

# 拷贝已有配置到指定目录下，此处4.11是proxychains-ng的版本号，请根据自己安装的版本号决定
cp /usr/local/Cellar/proxychains-ng/4.11/etc/proxychains.conf ~/.proxychains/proxychains.conf

# 修改配置
vim ~/.proxychains/proxychains.conf

[ProxyList]
# add proxy here ...
# meanwile
# defaults set to "tor"
# socks4 127.0.0.1 9095
socks5     127.0.0.1 1080
</pre>
PS：将tor代理9050注释，并添加`socks5     127.0.0.1 1080`

### 步骤三：测试
<pre>
proxychains4 curl https://twitter.com
</pre>

<p>如果能够正常返回html内容，则表示ok，否则进行步骤四</p>
<h3 id="步骤四：关闭SIP（针对第三步执行后扔无法翻墙）"><a href="#步骤四：关闭SIP（针对第三步执行后扔无法翻墙）" class="headerlink" title="步骤四：关闭SIP（针对第三步执行后扔无法翻墙）"></a>步骤四：关闭SIP（针对第三步执行后扔无法翻墙）</h3><p>新版MacOSX引入了SIP（System Integrity Protection）机制，需要关闭才可正常使用</p>
<pre>

<ol>
<li>重启电脑</li>
<li>长按Command+R键，直到系统进入Recovery Mode</li>
<li>打开终端(utilities -&gt; Terminal)，执行<code>csrutil disable</code></li>
<li>重启电脑（reboot）</li>
</ol>
<p></p></pre><br>PS：重启后，就可以正常跨过wall<p></p>
<h3 id="改进"><a href="#改进" class="headerlink" title="改进"></a>改进</h3><p>以上已经完成了翻墙功能，但是如果每次都输入proxychains4非常影响效率，于是我们可以借助alias命令进行改进</p>
<p><pre><br>alias fq=’proxychains4’<br></pre><br>PS: fq是源自翻墙的拼音，大家可以起其他更霸气的别名</p>
<p><pre><br>fq gitbook fetch 2.6.7<br></pre><br>PS：现在已经成功安装gitbook了</p>
</----------></pre>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/10/26/2016-10-26-SIP各业务逻辑流程/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/10/26/2016-10-26-SIP各业务逻辑流程/" itemprop="url">SIP各业务逻辑流程</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-10-26T00:00:00+08:00">
                2016-10-26
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/音视频/" itemprop="url" rel="index">
                    <span itemprop="name">音视频</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>近期在跟踪SIP问题，顺道把各个业务流程记录于此，方便后续查阅.</p>
<ul>
<li>SIPA - SIP客户端A</li>
<li>SIPB - SIP客户端B</li>
<li>SERVER - SIP服务器</li>
</ul>
<h4 id="注册注销流程"><a href="#注册注销流程" class="headerlink" title="注册注销流程"></a>注册注销流程</h4><pre>
SIPA                          SERVER
 |                               |
 |                               |
 |   --------REGISTER------->    |
 |                               |
 |   <---------401----------- |="" -----register(auth)----="">    |
 |                               |
 |   <-----------ok---------- |="" <="" pre="">

<h4 id="呼叫流程"><a href="#呼叫流程" class="headerlink" title="呼叫流程"></a>呼叫流程</h4><pre>
SIPA                          SERVER                           SIPB
 |                               |                              |
 |                               |                              |
 |   ---------INVITE-------->    |                              |
 |                               |                              |
 |   <---------trying-------- |="" ---------invite--------="">   |
 |                               |                              |
 |                               |   <---------trying-------- |="" <---------ringing-------="" <-----------ok----------="" -----------ack---------="">    |                              |
 |                               |   -----------ACK--------->   |
 |                               |                              |
 |                               |                              |
</---------trying--------></---------trying--------></pre>

<h4 id="变更会话（如切换音视频等）"><a href="#变更会话（如切换音视频等）" class="headerlink" title="变更会话（如切换音视频等）"></a>变更会话（如切换音视频等）</h4><pre>
SIPA                          SERVER                           SIPB
 |                               |                              |
 |                               |                              |
 |   ---------INVITE-------->    |                              |
 |                               |                              |
 |   <---------trying-------- |="" ---------invite--------="">   |
 |                               |                              |
 |                               |   <---------trying-------- |="" <-----------ok----------="" -----------ack---------="">    |                              |
 |                               |   -----------ACK--------->   |
 |                               |                              |
 |                               |                              |
</---------trying--------></---------trying--------></pre>

<h4 id="挂断"><a href="#挂断" class="headerlink" title="挂断"></a>挂断</h4><pre>
SIPA                          SERVER                           SIPB
 |                               |                              |
 |                               |                              |
 |   ----------BYE---------->    |                              |
 |                               |   ----------BYE---------->   |
 |                               |                              |
 |                               |   <-----------ok---------- |="" <-----------ok----------="" <="" pre="">
</-----------ok----------></pre></-----------ok----------></---------401-----------></pre>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/blog/page/9/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/blog/">1</a><span class="space">&hellip;</span><a class="page-number" href="/blog/page/9/">9</a><span class="page-number current">10</span><a class="page-number" href="/blog/page/11/">11</a><span class="space">&hellip;</span><a class="page-number" href="/blog/page/20/">20</a><a class="extend next" rel="next" href="/blog/page/11/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">smallmuou</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">197</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/blog/categories/index.html">
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/smallmuou" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-globe"></i>GitHub</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">smallmuou</span>

  
</div>

    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

    <span id="busuanzi_container_site_pv">总访问量<span id="busuanzi_value_site_pv"></span>次</span>
    <span class="post-meta-divider">|</span>



  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  

  

  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
